#pragma once

#include "maxtypes.h"
#include "matrix.h"
#include "hasname.h"
#include "refcounter.h"
#include <vector>
#include <string>
class INode;
class Mesh;
class Interval;

class CExportBone : public HasName
{
public:
    CExportBone() {
        Frames = NULL;
        NumFrames = 0;
    }
    ~CExportBone() {
        delete[] Frames;
    }

    int NumFrames;
    CMatrix* Frames;

    static CExportBone* BuildFromINode( INode *N, Interval Time, TimeValue Step );
    void Save( /*cFile &F*/ );
};

//////////////////////////////////////////////////////////////////////////////////////////////
// CExportAnimation
//////////////////////////////////////////////////////////////////////////////////////////////
class CExportAnimation : public HasName
{
public:
    CExportAnimation()
    {
        NumFrames = 0;
    }
    ~CExportAnimation()
    {
        for (vector<CExportBone*>::const_iterator it = BonesAnim.begin(); it != BonesAnim.end(); ++it)
        {
            delete *it;
        }
        BonesAnim.clear();
    }
    UINT NumFrames;
    UINT m_iStartBone;
    vector<CExportBone*> BonesAnim;
    static CExportAnimation* Load( /*cFile &F*/ );
    static CExportAnimation* BuildFromNode( INode *N, Interval Time, TimeValue Step );
    void Save( /*cFile &F, cLogFile &logF*/ );
    // needed because of recursion (in-order tree visiting)
    void AddBoneAnim( INode *N, Interval Time, TimeValue Step );
};

//////////////////////////////////////////////////////////////////////////////////////////////
// CExportAnimData
//////////////////////////////////////////////////////////////////////////////////////////////
class CExportAnimData : public RefCounter, public HasName
{
public:
    static const char* AnimPath;
    static CExportAnimData* Load( /*const string &szName, bool usedefpath = true*/ );
    ~CExportAnimData()
    {
        for (vector<CExportAnimation*>::const_iterator it = Anims.begin(); it != Anims.end(); ++it)
        {
            delete *it;
        }
        Anims.clear();
    }

    vector<CExportAnimation*> Anims;
    void Clear();

    void Save( const string& fn );
    void UpdateListBox( HWND hWnd );
};
